﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BLL;
using Model;

public partial class BaseData_UserMessageManagement : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        getAllMessage();
    }

    #region   获取所有留言列表
    /// <summary>
    ///  获取所有留言列表
    /// </summary>
    public void getAllMessage()
    {
        BLL.UserMessageBL myBL = new UserMessageBL();
        int recordCount = 0;
        List<UserMessage> myMessageList = new List<UserMessage>();
        string ret = myBL.GetAllMessage(this.CutPageBar1.PageIndex, this.CutPageBar1.PageSize, out recordCount, out myMessageList);
        if (ret.Equals("000000"))
        {
            this.CutPageBar1.RecordCount = recordCount;
            this.rptMessage.DataSource = myMessageList;
            this.rptMessage.DataBind();
        }
        else
        {

        }
    }
    #endregion

    #region  根据留言编号修改留言状态
    /// <summary>
    /// 修改一条留言
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void rptMessage_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        BLL.UserMessageBL myBL = new UserMessageBL();
        int messageId = SiteCommon.Common.GetInt(e.CommandArgument.ToString());
        int status = Convert.ToInt32(e.CommandName) == 1 ? 0 : 1;
        int rows = 0;
        string ret = myBL.UserMessageEdit(messageId, status, out rows);
        if (ret.Equals("000000"))
        {
            if (rows > 0)
            {
                getAllMessage();
            }
            else
            {
                SiteCommon.Common.alert("操作失败");
            }
        }
        else
        {
            SiteCommon.Common.alert(ret);
        }
    }
    #endregion

    #region   分页控件事件
    /// <summary>
    ///  分页控件事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CutPageBar1_OnPageIndexChanged1(object sender, SiteCommon.ChangePageArgs e)
    {
        this.CutPageBar1.PageIndex = e.PageIndex;
        this.getAllMessage();
    }
    #endregion

    #region   留言内容
    /// <summary>
    /// 留言内容
    /// </summary>
    /// <returns></returns>
    public string getMessageContent(string strContent)
    {
        return strContent.Length > 10 ? strContent.Substring(0, 8) + ".." : strContent;
    }
    #endregion

    #region   回复内容
    /// <summary>
    /// 回复内容
    /// </summary>
    /// <param name="strContent"></param>
    /// <returns></returns>
    public string getReplayContent(string strContent)
    {
        return strContent.Length == 0 ? "----" : strContent;
    }
    #endregion

    #region   回复内容长度
    /// <summary>
    /// 回复内容长度
    /// </summary>
    /// <param name="strContentBack"></param>
    /// <returns></returns>
    public string getBackContent(string strContentBack)
    {
        return strContentBack.Length > 10 ? strContentBack.Substring(0, 8) + ".." : strContentBack.Length < 1 ? "---" : strContentBack;
    }

    #endregion
    #region  获取状态

    public string getshowFlag(int i)
    {
        return i == 1 ? "显示" : "隐藏";
    }

    #endregion
    #region  操作状态

    public string getOperationshowFlag(int i)
    {
        return i == 1 ? "隐藏" : "显示";
    }

    #endregion
}
